#ifndef _DEPTH_INTERVAL_
#define _DEPTH_INTERVAL_

// Includes:
// --------
#include "interval.h"
#include <iostream>

using namespace std;

// ----------------------------------
class DepthInterval : public Interval
// ----------------------------------
{
	// Members:
	// -------
	private:
		float near;
		float far;
	
	public:
		// ---------------------------------
		DepthInterval(float near, float far)
			: near(near), far(far){}
		// ---------------------------------

		// --------------
		DepthInterval(){}
		// --------------

		// -----------------------
		virtual ~DepthInterval(){}
		// -----------------------
		
		// ----------------------
		float GetLowPoint() const
		// ----------------------
		{
			return near;
		}

		// -----------------------
		float GetHighPoint() const
		// -----------------------
		{
			return far;
		}

		// ------------------------------------------
		DepthInterval Intersect(DepthInterval& other)
		// ------------------------------------------
		{
			float near = max(this->near, other.near);
			float far = min(this->far, other.far);
			return DepthInterval(near, far);
		}

		// -----------
		bool isEmpty()
		// -----------
		{
			return far < near;
		}

		// -------------------
		bool contains(float d)
		// -------------------
		{
			return (d >= near && d <= far);
		}

		// -----------------
		virtual void Print()
		// ----------------
		{
			cout << "(" << this->near << ", " << this->far << ")" << endl;
		}	
};

#endif /* _DEPTH_INTERVAL_ */
